package demo1;

/**
 * @Author liangzai
 * @Description:
 */
public class Training {
    public int maxProfit(int[] prices) {
        if (prices.length<=1){
            return 0;
        }
        int a = 0;
        for (int i = 1; i < prices.length; i++) {
            if (prices[i]>prices[i-1]){
                a+= (prices[i]-prices[i-1]);
            }
        }
        return a;
    }
}
